import * as echarts from "echarts"
/**
 * 颜色
 */
const countryColors = [
  "#0984e3",
  "#55efc4",
  "#fdcb6e",
  "#8dd8e8",
  "#rgb(152, 214, 228)",
  "#000",
  "#f93",
  "#bc002d",
]

/**
饼状图
 * @param {*} xAxis x轴数据
 * @param {*} data  y轴数据
 * @returns
 */
export const environmentalOpt = (title, data) => {
  return {
    title: {
      text: title,

      left: 'center'
    },
    tooltip: {
      trigger: 'item'
    },


    series: [
      {
        label: {
          alignTo: 'edge',
          formatter: '{name|{b}}\n{time|{c} }',
          minMargin: 5,
          edgeDistance: '10%',
          lineHeight: 15,
          bleedMargin: 10,
          rich: {
            time: {
              fontSize: 10,
              color: '#999'
            }
          }
        },
        type: 'pie',
        radius: '50%',
        data,
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        }
      }
    ]
  }
}

/**柱状图 */

export const barOpt = (title, xAxis, yAxis) => {
  console.log(xAxis, yAxis, 'yAxis');
  return {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'shadow'
      }
    },
    title: {
      text: title,

      left: 'center'
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      top: '15%',
      containLabel: true
    },
    xAxis: [
      {
        type: 'category',
        data: xAxis,
        axisTick: {
          alignWithLabel: true
        }
      }
    ],
    yAxis: [
      {
        type: 'value'
      }
    ],
    series: [
      {

        type: 'bar',
        barWidth: '60%',
        data: yAxis,
        label: {
          show: true,
          formatter: (params) => Math.round(params.value * 1000) / 10 + '%',
          position: "top",

        },
      }
    ]
  };
}


